package com.realife.eson.common.config;

import feign.Logger;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
public class OpenFeignConfig {

    @Bean
    Logger.Level feignLoggerLevel() {
        return Logger.Level.FULL;
    }


    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    @Bean
    public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {

        PoolingHttpClientConnectionManager pcm = new PoolingHttpClientConnectionManager();

        //爬虫服务器最大连接数
        pcm.setMaxTotal(200);
        //每个Host网站主机分配的最大连接数
        pcm.setDefaultMaxPerRoute(200);

        return pcm;
    }

}
